﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CILADA.TestAssembly;

namespace CILADA.TestAssemblyTwo
{
    class InterfaceInConstructor
    {
        public InterfaceInConstructor(IPet pet)
        {
            // do nothing
        }
    }

    class GenericWriter
    {
        public string Write<T>(T item)
        {
            return item.ToString();
        }

        public string WriteTo<U>(U item)
        {
            return item.ToString();
        }
    }

    #region These methods compile to the same IL.
    class PetObjectWriter
    {
        public void Write<T>(T pet) where T: IPet
        {
            Console.WriteLine((object)pet.ToString());
        }
    }

    class PetWriter
    {
        public void Write<T>(T pet) where T : IPet
        {
            Console.WriteLine(pet.ToString());
        }
    }
    #endregion

    class PetNameWriter
    {
        public void Write<T>(T pet) where T : IPet
        {
            Console.WriteLine(pet.PetName);
        }
    }

    class DogObjectWriter
    {
        public void Write<T>(T dog) where T : Dog
        {
            Console.WriteLine((object)dog.ToString());
        }
    }

    class DogWriter
    {
        public void Write<T>(T dog) where T : Dog
        {
            Console.WriteLine(dog.ToString());
        }
    }

    class DogToyWriter
    {
        public void Write<T>(T dog) where T : Dog
        {
            Console.WriteLine(dog.FavToy.ToString());
        }
    }
}
